package com.koron.css2.workflow;

import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.css2.workflow.bean.OverdueDelayQuery;
import com.koron.css2.workflow.bean.OverdueHistoryBean;
import com.koron.css2.workflow.mapper.OverdueDelayListMapper;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

public class OverdueDelayList implements ServerInterface {
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            OverdueDelayQuery overdueDelayQuery = JsonUtils.objectToPojo(req.getData(), OverdueDelayQuery.class);
            OverdueDelayListMapper mapper = factory.getMapper(OverdueDelayListMapper.class);
            String processInstanceId = mapper.selectprocessInstanceId(overdueDelayQuery.getBillId());
            OverdueHistoryBean overdueInfo = WorkflowImpl.getOverdueInfo(overdueDelayQuery.getProcessSetCode(), overdueDelayQuery.getProcessCode(), processInstanceId);
            MessageBean<OverdueHistoryBean> message = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "", OverdueHistoryBean.class);
            message.setData(overdueInfo);
            return message;
        } catch (Exception e) {
            logger.error("超期历史查询失败", e);
        }
        return MessageBean.create(Constant.MESSAGE_INT_FAIL, "超期历史查询失败", null);
    }
}
